# coding: utf-8

import os
import datetime
import math
import set_env_path

from sqlalchemy import create_engine
from sqlalchemy.sql import text

from common.wechat_util import update_users_tag

engine = create_engine(
    os.getenv('DATABASE_URL')
    or 'mysql+pymysql://root:@127.0.0.1/wph_www_prod?charset=utf8'
)
conn = engine.connect()

def main():
    sql_1 = text("""
update
	user_info
set
	user_info.app_first_login_time = '2018-08-04 12:00:00'
where
	user_id in (
	select
		id
	from
		user
	where
		mobile in ( '15840397297',
		'18802477551',
		'17390001333',
		'13578916672',
		'17758887830',
		'13074517877',
		'18636605699',
		'18686003890',
		'18732103333',
		'15030190087',
		'13641336389',
		'15026698878',
		'18969127575',
		'18858313888',
		'18013913111',
		'13851694193',
		'18629246563',
		'17719502550',
		'13893421777',
		'18693109206',
		'13579909201',
		'18195800017',
		'18609500895',
		'18971555571',
		'15902792811',
		'13507919300',
		'15083559703',
		'15159555689',
		'13358305085',
		'19907487001',
		'13875885048',
		'18982006321',
		'15002868180',
		'13984057103',
		'15086808882',
		'18323381208',
		'13489291111',
		'13529119825',
		'13987127257',
		'15507887435',
		'15385511088',
		'15966644444',
		'18653953565',
		'18638683888',
		'13838017230' ))
	and app_first_login_time is null;
    """)

    sql_2 = text("""
update
	user
SET
	type=100
where
	mobile in ( '15840397297',
	'18802477551',
	'17390001333',
	'13578916672',
	'17758887830',
	'13074517877',
	'18636605699',
	'18686003890',
	'18732103333',
	'15030190087',
	'13641336389',
	'15026698878',
	'18969127575',
	'18858313888',
	'18013913111',
	'13851694193',
	'18629246563',
	'17719502550',
	'13893421777',
	'18693109206',
	'13579909201',
	'18195800017',
	'18609500895',
	'18971555571',
	'15902792811',
	'13507919300',
	'15083559703',
	'15159555689',
	'13358305085',
	'19907487001',
	'13875885048',
	'18982006321',
	'15002868180',
	'13984057103',
	'15086808882',
	'18323381208',
	'13489291111',
	'13529119825',
	'13987127257',
	'15507887435',
	'15385511088',
	'15966644444',
	'18653953565',
	'18638683888',
	'13838017230' );
    """)

    conn.execute(sql_1)
    conn.execute(sql_2)


if __name__ == '__main__':
    main()
